Repository navigation
feat(libkernel): report machdep.tsc_freq through sysctlbyname - #5078
Closed
p3n1cillin wants to merge 1 commit into
Closed
p3n1cillin wants to merge 1 commit into
p3n1cillin wants to merge 1 commit into
Conversation
PS5SX2 (PPSA99203) reads machdep.tsc_freq at start-up and stopped on the unsupported name. It reports the host TSC frequency that sceKernelGetTscFrequency measures, as guest rdtsc reads the host counter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
Linux run of this change: Ubuntu in WSL2, GCC 15.2.0, Ninja Release, |
This was referenced Oct 13, 2026
|
Tested on Linux x86-64 (Release build), with 46f3d77 cherry-picked onto main 14036cb:
It also cherry-picks cleanly together with #5098, which edits the same files. |
This was referenced Oct 13, 2026
This was referenced Oct 13, 2026
10 tasks done
11 tasks done
Collaborator
|
Closing: same change as #4776, which came first and is now merged. Reopen if something here is still missing on current main. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
PS5SX2 (PPSA99203, catalog release) stops right after its "starting" notification on Windows:
The caller is its boot-time clock survey (guest 0x7428E, next to its
[cpuclk] boot: measured TSC ...and[console] CPU: %llu Hzstrings). Read with gdb atsysctlbynameand disassembled, it callssysctlbyname("machdep.tsc_freq", &u64, &len = 8, NULL, 0). It uses the value when the call returns 0 and the value is above 100 MHz; otherwise it measures the TSC against its monotonic clock for 50 ms. The repository's main-boot.cpp has the other call, which also readsmachdep.tsc_freqas anunsigned long long. That one runs only whensceKernelGetCpuFrequencyreturns 0, which AnyPS5's never does.machdep.tsc_freqis FreeBSD's 64-bitsysctl_machdep_tsc_freq, present on every amd64 kernel with a TSC.sysctlbynamenow reports the host TSC frequency thatsceKernelGetTscFrequencyalready measures, because guestrdtscreads the host counter. It uses the existingCopyOut, so a null buffer gets the length 8 and a short buffer gets a partial copy andENOMEM, assysctl_handle_64does. A write, which FreeBSD would take as a new frequency, throws. The console's value is unknown; this is recorded under Unknown function info indocs/dev/debt/libkernel.md.Tested
--trap-sdk-syscall-stubs(a forbidden inline syscall), so this run used that debugging flag; no trapped instruction was reached. Before, it stops as above within 1 s. After, it runs for the whole 90 s run and keeps rewriting itsdata/PCSX2/ps5sx2-alive.txtheartbeat; nothing else reached was checked.guest_system_configuration: the length query, the value (nonzero and equal tosceKernelGetTscFrequency, witherrnountouched), a 4-byte buffer (ENOMEM, 4 bytes copied, the rest untouched) and a throwing write. All 124 libkernel tests pass on Windows; Linux was not built locally.python tools/check_conventions.py --base origin/mainandtools/pr_overlap.pypass.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)--trap-sdk-syscall-stubs🤖 Generated with Claude Code